/*
PARI/GP script to prepare an integer sequence data for OEIS
=============================================================
File: WriteIntSeqForOEIS.txt    
Link: https://oeis.org/wiki/File:WriteIntSeqForOEIS.txt
=============================================================
Last update: 19 Nov 2016
This file is now obsolete: content was merged with EbIo.txt
*/


WriteIntSeqForOEIS(file,vect,offset,dumpall=0) = 
/* ----------------------------------------------------------
  Writes into a text file all one needs to submit to OEIS a
  vector of integers. The idea is that the vector is first
  computed and then the file is generated.

  Writes (appends!) the following text into the output file:
  <OFFSET:> \\ the value specified in the 'offset' argument
  <DATA:>
    <the entries of vect until exhausted, but not exceeding
     260 characters>
  <B-File:>   
    <offset   v[1]>
    <offset+1 v[2]>
    <offset+2 v[3]>
    \\ etc., but see the next comment

  When the default (0) is used for dumpall, the output will
  terminate just before the first entry with >= 1000 digits 
  (if present). Otherwise, if dumpall is nonzero, all items
  are dumped, no matter how long.

  User instructions:
  a) Compute your integer sequence with as many elements as
     you can but not more than the maximum you want to appear
     in the b-file.
  b) Run the script, making sure to set the correct offset.
  c) Open the output file with Notepad or Wordpad.
     - First, there is a line reporting the OFFSET: value.
     - Then, there is a block introduced by a line labelled
       "DATA:" and containing of at most 260 characters,
       with entries separated by comma+space. These are
       to be copy/pasted into the OEIS DATA section.
     - Finally, there is a line labelled "B-File:", followed
       by two properly indexed columns which constitute the
       actual B-File. It extends until the whole vector is
       dumped, or until an entry has 1000 or more digits.

  To prepare the B-File, extract the section starting just
  after the line saying "B-File:" and extending up to the
  end of the file.
  
  Note: Should any of the 1st to 4th entries exceed 260
     characters, you have a special case. Less than 4 items
     will be dumped in DATA and you should better discuss
     the case with an OEIS editor.

  Example:
   WriteIntSeqForOEIS("c:\\myparidir\\b12345.txt",vect1D,1)
---------------------------------------------------------- */
{
  my (s=260);
  write(file,"OFFSET: ",offset,"\n\nDATA:");
  s -= sizedigit(vect[1]);
  for(i=1,#vect, if(s<=0,break);write1(file,vect[i]);
    if (i<#vect, s-=sizedigit(vect[i+1])+2;
        if (s>0,write1(file,", ")));
  );
  write(file,"\n\nB-File:");
  for(i=1,#vect,
    if((dumpall==0)&&(sizedigit(vect[i])>=1000),break); 
    write(file,offset+i-1," ",vect[i]);
  );
}


/*
=============================================================
   Contributed to OEIS Wiki by Stanislav Sykora
=============================================================
*/

